package com.example.java_chatroom.service;

import com.example.java_chatroom.mapper.MessageSessionMapper;
import com.example.java_chatroom.model.Friend;
import com.example.java_chatroom.model.MessageSession;
import com.example.java_chatroom.model.MessageSessionUser;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageSessionService {
    @Resource
    private MessageSessionMapper messageSessionMapper;

    public List<Integer> getSessionIdsByUserId(int userId){
        return messageSessionMapper.getSessionIdsByUserId(userId);
    }

    //    2、根据sessionId再查询这个会话都包括了哪些用户，（刨除最初的自己）
    public List<Friend> getFriendsBySessionId(int sessionId, int selfUserId){
        return messageSessionMapper.getFriendsBySessionId(sessionId,selfUserId);
    }

    public int addMessageSession(MessageSession messageSession){
        return messageSessionMapper.addMessageSession(messageSession);
    }

    public int addMessageSessionUser(MessageSessionUser messageSessionUser){
        return messageSessionMapper.addMessageSessionUser(messageSessionUser);
    }
}
